package zx.x.modules.app.controller;

import java.util.Arrays;
import java.util.Map;

import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import zx.x.modules.app.entity.TsjyEntity;
import zx.x.modules.app.service.TsjyService;
import zx.x.common.utils.PageUtils;
import zx.x.common.utils.R;



/**
 * 投诉建议
 *
 * @author x
 * @email x
 * @date 2023-01-14 14:07:19
 */
@RestController
@RequestMapping("/app/tsjy")
public class TsjyController {
    @Autowired
    private TsjyService tsjyService;

    /**
     * 列表
     */
    @RequestMapping("/list")
    @RequiresPermissions("app:tsjy:list")
    public R list(@RequestParam Map<String, Object> params){
        PageUtils page = tsjyService.queryPage(params);

        return R.ok().put("page", page);
    }


    /**
     * 信息
     */
    @RequestMapping("/info/{id}")
    @RequiresPermissions("app:tsjy:info")
    public R info(@PathVariable("id") Integer id){
		TsjyEntity tsjy = tsjyService.getById(id);

        return R.ok().put("tsjy", tsjy);
    }

    /**
     * 保存
     */
    @RequestMapping("/save")
    public R save(TsjyEntity tsjy){
		tsjyService.save(tsjy);

        return R.ok();
    }

    /**
     * 修改
     */
    @RequestMapping("/update")
    @RequiresPermissions("app:tsjy:update")
    public R update(@RequestBody TsjyEntity tsjy){
		tsjyService.updateById(tsjy);

        return R.ok();
    }

    /**
     * 删除
     */
    @RequestMapping("/delete")
    @RequiresPermissions("app:tsjy:delete")
    public R delete(@RequestBody Integer[] ids){
		tsjyService.removeByIds(Arrays.asList(ids));

        return R.ok();
    }

}
